home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / Newton Platform Info / Newton 2.0 Sample Code / Routing / CustomRoute-2 / Constants next >
Encoding:
Text File  |  1995-11-21  |  2.5 KB  |  65 lines  |  [TEXT/NTP1]

  1. /*
  2. **      Newton Developer Technical Support Sample Code
  3. **
  4. **      Custom Route, a Newton 2.0 routing example
  5. **
  6. **      by J. Christopher Bell, Newton Developer Technical Support
  7. **
  8. **      Copyright © 1994-5 by Apple Computer, Inc.  All rights reserved.
  9. **
  10. **      You may incorporate this sample code into your applications without
  11. **      restriction.  This sample code has been provided "AS IS" and the
  12. **      responsibility for its operation is 100% yours.  You are not
  13. **      permitted to modify and redistribute the source as "DTS Sample Code."
  14. **      If you are going to re-distribute the source, we require that you
  15. **      make it clear in the source that the code was descended from
  16. **      Apple-provided sample code, but that you've made changes.
  17. */
  18.  
  19. constant kMyMainDataDefSym     := '|myDataDef:customRoute:PIEDTS| ;
  20. constant kMyMainViewDefSym     := '|myViewDef:customRoute:PIEDTS| ;
  21. constant kMyFrameViewDefSym := '|myFrameViewDef:customRoute:PIEDTS| ;
  22.  
  23.  
  24. // Get the cup icon
  25. OpenResFile(home & "pictures");
  26. DefConst('kCupIcon, GetPictAsBits("minRouteIcon", nil));
  27. CloseResFile();
  28.  
  29.  
  30. /*
  31.  * This is a routing format which handles 'text and 'frame (despite the name, protoFrameFormat
  32.  * handles both types. If you want to handle just 'frames, override the dataTypes slot with ['frame].
  33.  *
  34.  * This will be registered in the application installScript with RegisterViewDef(...).
  35.  *
  36.  * Note that we won't necessarily be able to view the item in the iobox unless we write a 
  37.  * NON-ROUTING viewDef for kMyMainDataDefSym so that it can be viewed in the iobox item viewer.
  38.  */
  39. DefConst('kMyFrameRoutingFormat, {    
  40.     _proto:        protoFrameFormat,
  41.     title:        "CustomRoute - picture choice", 
  42.     version:    1, 
  43.     symbol:        kMyFrameViewDefSym, 
  44.     SetupItem:    func(item, targetInfo) 
  45.         begin
  46.             inherited:?SetupItem(item, targetInfo);
  47.             /*If you have any "preprocessing" to do like set anything in the item or add
  48.              * extra body slots like version slots, or extra data, you can do it here, but if you are
  49.              * trying to actually prep visual shapes, do that in formatInitScript.        
  50.              * 
  51.              * Note that by calling inherited, we get the equivalent of:
  52.              *        item.body := targetInfo.target;
  53.              * ...plus if the target is a soup entry alias, it resolves it...
  54.              *
  55.              * Only modify the item, not the target.
  56.              */
  57.  
  58.             // set the title; note that the string will be editable by the user...
  59.             item.title := "CustomRoute item: " & datentime(time());
  60.  
  61.             item;
  62.         end,
  63.     textScript: func(fields, target)
  64.         clone(target.data);    // our target.data should always be plain text
  65. });